package com.hyw.supply.model.vo;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LoginUserVO implements UserDetails {

    @Schema(title = "id", description = "用户名")
    private Long id;

    @Schema(title = "name", description = "名称")
    private String name;

    @Schema(title = "account", description = "登录账户")
    private String account;

    @Schema(title = "password", description = "登录密码")
    private String password;

    @Schema(title = "enterprise", description = "企业名称")
    private String enterprise;

    @Schema(title = "admined", description = "是否为管理员true是false否")
    private Boolean admined;

    @JsonIgnore
    private List<? extends GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.name;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
